home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CRYPT19.ZIP / PW_EXE.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-08-05  |  6.3 KB  |  226 lines

  1. ;─────────────────────────────────────────────────────────────────────────────
  2. ;                   Black Wolf's File Protection Utilities 2.1s
  3. ;
  4. ;PW_EXE - Password Code for EXE file password protection in PassEXE.
  5. ;         If modified, convert to data bytes and re-instate program into
  6. ;         PassEXE.ASM, then recompile PassEXE.
  7. ;      
  8. ;         Basically, this code is attached to a .EXE file and, when executed,
  9. ;         waits for a password - if it is legit it continues, otherwise it       
  10. ;         stops execution of the file.
  11. ;
  12. ;LISCENSE:
  13. ;    Released As Freeware - These files may be distributed freely.
  14. ;
  15. ;Any modifications made to this program should be listed below the solid line,
  16. ;along with the name of the programmer and the date the file was changed.
  17. ;Also - they should be commented where changed.
  18. ;
  19. ;NOTE THAT MODIFICATION PRIVILEDGES APPLY ONLY TO THIS VERSION (2.1s)!  
  20. ;I'd appreciate notification of any modifications if at all possible, 
  21. ;reach me through the address listed in the documentation file (bwfpu21s.doc).
  22. ;
  23. ;DISCLAIMER:  The author takes ABSOLUTELY NO RESPONSIBILITY for any damages
  24. ;resulting from the use/misuse of this program/file.  The user agrees to hold
  25. ;the author harmless for any consequences that may occur directly or 
  26. ;indirectly from the use of this program by utilizing this program/file
  27. ;in any manner.
  28. ;─────────────────────────────────────────────────────────────────────────────
  29. ;Modifications:
  30. ;       None as of 08/05/93 - Initial Release.
  31.  
  32. .model tiny
  33. .radix 16
  34. .code
  35.         org 100
  36. start:
  37. ;        push    es ds
  38. ;                       ;These commands are placed _before_ the ultimute
  39. ;        push    cs cs  ;encryption.
  40. ;        pop     es ds
  41.         
  42.         call    Get_Offset
  43. Displaced:
  44.         mov     byte ptr [tr1+bp],0c3   ;move a return onto tr1 for debug..
  45. tr1:
  46.         jmp     tr2
  47. tr2:
  48.         cli
  49.         push    ax ds
  50.         xor     ax,ax
  51.         mov     ds,ax
  52.         lea     ax,[Print_Prompt+bp]
  53.         xchg    ax,word ptr ds:[00]
  54.         push    ax
  55.         mov     ax,cs
  56.         xchg    ax,word ptr ds:[02]
  57.         push    ax
  58.         push    ds
  59.         push    cs
  60.         pop     ds
  61.         mov     word ptr cs:[Change_Div+bp],9090        
  62.         xor     cx,cx
  63. Change_Div:                             ;That X/0 trick again....
  64.         div     cx
  65.         pop     ds
  66.         pop     ax
  67.         xchg    ax,word ptr ds:[02]
  68.         pop     ax
  69.         xchg    ax,word ptr ds:[00]
  70.         pop     ds ax
  71.         sti
  72.  
  73. GetthePass:
  74.         call    Getpass
  75. aftergp:
  76.         call    Encrypt_Password
  77.         call    Check_Passwords
  78.         jc      BadPass
  79.         
  80.         xor     ax,ax
  81.         mov     cx,0c
  82.         lea     si,[Entered_Pass+bp]
  83.  
  84. GetValue:                               ;Get value to use to decrypt with..
  85.         lodsb
  86.         add     ah,al
  87.         ror     ah,1
  88.         loop    GetValue
  89.                                                 ;I need an improved algorithm
  90.         lea     si,[Goodpass+bp]                ;here.......
  91.         mov     cx,EndGoodPass-GoodPass        
  92.  
  93. Decrypt_Restore:        
  94.         mov     al,[si]
  95.         xor     al,ah
  96.         mov     [si],al
  97.         inc     si
  98.         loop    Decrypt_Restore
  99.         call    RenewPrefetch
  100.         jmp     short GoodPass
  101.         
  102.         db      0ff
  103. GoodPass:        
  104.         pop     es ds
  105.         mov     ax,es
  106.         add     ax,10
  107.         add     word ptr cs:[Old_CS+bp],ax
  108.         
  109.         add     ax,word ptr cs:[Old_SS+bp]
  110.         
  111.         cli
  112.         mov     ss,ax
  113.         mov     sp,word ptr cs:[Old_SP+bp]
  114.         sti
  115.         
  116.         xor     ax,ax
  117.         mov     si,ax
  118.         mov     di,ax
  119.  
  120.         jmp     dword ptr cs:[Old_IP+bp]
  121.         nop
  122.         nop
  123.         nop
  124.         nop
  125. EndGoodPass:
  126.         db      0ff
  127.  
  128. BadPass:        
  129.         mov     ah,09
  130.         lea     dx,[BadBad+bp]
  131.         int     21
  132.         mov     ax,4c01
  133.         int     21
  134. BadBad  db      0a,0dh,'Password Incorrect.',07,24
  135.  
  136. RenewPrefetch:
  137.         nop
  138.         jmp     loc1
  139. loc2:        
  140.         clc
  141.         ret
  142. loc1:
  143.         cld
  144.         jmp     loc2
  145.  
  146. ;------------------------------------------------------------------------
  147. Check_Passwords:
  148.         lea     si,[bp+Entered_Pass]
  149.         lea     di,[Password+bp]
  150.         mov     cx,0c
  151.         repz    cmpsb
  152.         jcxz    Password_Good
  153.         stc
  154.         ret
  155.  
  156. Password_Good:
  157.         clc
  158.         ret
  159. ;------------------------------------------------------------------------
  160. Encrypt_Password:
  161.         mov     bx,word ptr [Key1+bp]
  162.         mov     dx,word ptr [Key2+bp]
  163.         lea     si,[Entered_Pass+bp]
  164.         mov     di,si
  165.         mov     cx,6
  166.   EncryptIt:      
  167.         lodsw
  168.         xor     ax,bx
  169.         add     bx,dx
  170.         stosw
  171.         loop    EncryptIt
  172.         ret
  173. ;------------------------------------------------------------------------
  174. GetPass:
  175.         mov     cx,0c
  176.         lea     di,[Entered_Pass+bp]
  177.   KeyHit_Loop:
  178.         push    cx
  179.         sub     ax,ax
  180.         int     16
  181.         cmp     al,0dh
  182.         je      HitReturn
  183.         stosb
  184.         pop     cx
  185.         loop    KeyHit_Loop
  186.         ret
  187.   
  188.   HitReturn:
  189.         pop     cx
  190.         xor     al,al
  191.         repnz   stosb
  192.         ret        
  193. ;------------------------------------------------------------------------
  194. Print_Prompt:
  195.         mov     ah,09
  196.         lea     dx,[Info+bp]
  197.         int     21
  198.         iret
  199. Info    db      'Password->',24
  200. ;------------------------------------------------------------------------
  201. Get_Offset:
  202.         pop     bp
  203.         jmp     short confuzzled
  204.         db      0ea
  205. confuzzled:
  206.         push    bp
  207.         sub     bp,offset Displaced
  208.         ret
  209.  
  210. ;------------------------------------------------------------------------
  211. ;------------------------------------------------------------------------
  212. Key1            dw      0
  213. Key2            dw      0
  214. ;------------------------------------------------------------------------
  215. Old_IP  dw      0
  216. Old_CS  dw      0fff0
  217. Old_SS  dw      0fff0
  218. Old_SP  dw      0
  219. ;------------------------------------------------------------------------
  220. Password        db      'TestPassword'
  221. Entered_Pass    db      '            '
  222. ;------------------------------------------------------------------------
  223. Header:
  224. end_prog:
  225. end start
  226.